﻿package idv.cjcat.shintaz.compiler.scanner {
	
	public class Token {
		
		//key words
		public static const BREAK		:Token = new Token(TokenType.BREAK, "break");
		public static const CASE		:Token = new Token(TokenType.CASE, "case");
		public static const CONTINUE	:Token = new Token(TokenType.CONTINUE, "continue");
		public static const DEFAULT		:Token = new Token(TokenType.DEFAULT, "default");
		public static const DELETE		:Token = new Token(TokenType.DELETE, "delete");
		public static const DO			:Token = new Token(TokenType.DO, "do");
		public static const ELSE		:Token = new Token(TokenType.ELSE, "else");
		public static const FOR			:Token = new Token(TokenType.FOR, "for");
		public static const FUNCTION	:Token = new Token(TokenType.FUNCTION, "function");
		public static const IF			:Token = new Token(TokenType.IF, "if");
		public static const NEW			:Token = new Token(TokenType.NEW, "new");
		public static const RETURN		:Token = new Token(TokenType.RETURN, "return");
		public static const SWITCH		:Token = new Token(TokenType.SWITCH, "switch");
		public static const THIS		:Token = new Token(TokenType.THIS, "this");
		public static const VAR			:Token = new Token(TokenType.VAR, "var");
		public static const WHILE		:Token = new Token(TokenType.WHILE, "while");
		
		public static const TRUE		:Token = new Token(TokenType.BOOL, true);
		public static const FALSE		:Token = new Token(TokenType.BOOL, false);
		
		public static const NULL		:Token = new Token(TokenType.NULL, "null");
		public static const UNDEFINED	:Token = new Token(TokenType.UNDEFINED, "undefined");
		
		
		//delimiters
		public static const BRACE_L		:Token = new Token(TokenType.BRACE_L, "{");
		public static const BRACE_R		:Token = new Token(TokenType.BRACE_R, "}");
		public static const BRACK_L		:Token = new Token(TokenType.BRACK_L, "[");
		public static const BRACK_R		:Token = new Token(TokenType.BRACK_R, "]");
		public static const PAREN_R		:Token = new Token(TokenType.PAREN_L, "(");
		public static const PAREN_L		:Token = new Token(TokenType.PAREN_R, ")");
		public static const COMMA		:Token = new Token(TokenType.COMMA, ",");
		public static const DOT			:Token = new Token(TokenType.DOT, ".");
		public static const S_COLON		:Token = new Token(TokenType.S_COLON, ";");
		public static const QUESTION	:Token = new Token(TokenType.QUESTION, "?");
		public static const COLON		:Token = new Token(TokenType.COLON, ":");
		
		//operators
		public static const PLUS		:Token = new Token(TokenType.PLUS, "+");
		public static const MINUS		:Token = new Token(TokenType.MINUS, "-");
		public static const MUL			:Token = new Token(TokenType.MUL, "*");
		public static const DIV			:Token = new Token(TokenType.DIV, "/");
		public static const INCRE		:Token = new Token(TokenType.INCRE, "++");
		public static const DECRE		:Token = new Token(TokenType.DECRE, "--");
		
		public static const LT			:Token = new Token(TokenType.LT, "<");
		public static const GT			:Token = new Token(TokenType.GT, ">");
		public static const EQ			:Token = new Token(TokenType.EQ, "==");
		public static const LE			:Token = new Token(TokenType.LE, "<=");
		public static const GE			:Token = new Token(TokenType.GE, ">=");
		public static const NEQ			:Token = new Token(TokenType.NEQ, "!=");
		
		public static const AND			:Token = new Token(TokenType.AND, "&&");
		public static const OR			:Token = new Token(TokenType.OR, "||");
		public static const NOT			:Token = new Token(TokenType.NOT, "!");
		
		public static const BIT_AND		:Token = new Token(TokenType.BIT_AND, "&");
		public static const BIT_OR		:Token = new Token(TokenType.BIT_OR, "|");
		public static const BIT_XOR		:Token = new Token(TokenType.BIT_XOR, "^");
		public static const BIT_NOT		:Token = new Token(TokenType.BIT_NOT, "~");
		
		public static const SHIFT_L		:Token = new Token(TokenType.SHIFT_L, ">>");
		public static const SHIFT_R		:Token = new Token(TokenType.SHIFT_R, "<<");
		public static const USHIFT_L	:Token = new Token(TokenType.USHIFT_L, ">>>");
		public static const USHIFT_R	:Token = new Token(TokenType.USHIFT_R, "<<<<");
		
		
		//assignments
		public static const ASSIGN			:Token = new Token(TokenType.ASSIGN, "=");
		public static const ASSIGN_PLUS		:Token = new Token(TokenType.ASSIGN_PLUS, "+=");
		public static const ASSIGN_MINUS	:Token = new Token(TokenType.ASSIGN_MINUS, "-=");
		public static const ASSIGN_MUL		:Token = new Token(TokenType.ASSIGN_MUL, "*=");
		public static const ASSIGN_DIV		:Token = new Token(TokenType.ASSIGN_DIV, "/=");
		public static const ASSIGN_BIT_AND	:Token = new Token(TokenType.ASSIGN_BIT_AND, "&=");
		public static const ASSIGN_BIT_OR	:Token = new Token(TokenType.ASSIGN_BIT_OR, "|=");
		public static const ASSIGN_BIT_XOR	:Token = new Token(TokenType.ASSIGN_BIT_XOR, "^=");
		public static const ASSIGN_BIT_NOT	:Token = new Token(TokenType.ASSIGN_BIT_NOT, "~=");
		public static const ASSIGN_SHIFT_L	:Token = new Token(TokenType.ASSIGN_SHIFT_L, "<<=");
		public static const ASSIGN_SHIFT_R	:Token = new Token(TokenType.ASSIGN_SHIFT_R, ">>=");
		public static const ASSIGN_USHIFT_L	:Token = new Token(TokenType.ASSIGN_USHIFT_L, "<<<=");
		public static const ASSIGN_USHIFT_R	:Token = new Token(TokenType.ASSIGN_USHIFT_R, ">>>=");
		
		public var type:int;
		public var value:*;
		
		public function Token(type:int, value:* = null) {
			this.type = type;
			this.value = value;
		}
		
		public function toString():String {
			return "[Token type=" + type + " value=" + value + "]";
		}
	}
}